package com.xcity.tools.template;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class FinancialConvert {

	static class Financial {
		@Comment("理财产品编号")
		int id;
		@Comment("产品名")
		String name;
		@Comment("年化收益率%")
		int rate;
		@Comment("周期(天)")
		int period;
		@Comment("投资总额")
		long total;
		@Comment("起投金额")
		int min;
	}
	
	static final File PARENT = new File("F:/prj_java/city_doc/策划/配置表");
	
	public static void main(String[] args) {
		
	}

	static List<Financial> parse(File file) throws Exception {
		Workbook book = getWorkbook(file);
		Sheet sheet = book.getSheetAt(0);
		int from = 3;
		int to = sheet.getLastRowNum();
		List<Financial> list = new ArrayList<Financial>();
		for (int i = from; i <= to; i++) {
			Row row = sheet.getRow(i);
			
		}
		return list;
	}
	
	static Workbook getWorkbook(File file) throws Exception {
		if (file.getName().endsWith("xlsx")) {
			return new XSSFWorkbook(file);
		}
		return new HSSFWorkbook(new FileInputStream(file));
	}
	
}
